import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 供应商评价
 */
@Entity('supplier_evaluation')
export class SupplierEvaluationEntity extends BaseEntity {
  @Index()
  @Column({ comment: '供应商ID' })
  supplierId: number;

  @Column({ comment: '质量评分', dict: ['1', '2', '3', '4', '5'], default: 4 })
  qualityScore: number;

  @Column({ comment: '交付评分', dict: ['1', '2', '3', '4', '5'], default: 4 })
  deliveryScore: number;

  @Column({ comment: '服务评分', dict: ['1', '2', '3', '4', '5'], default: 4 })
  serviceScore: number;

  @Column({
    comment: '综合评分',
    type: 'decimal',
    precision: 3,
    scale: 1,
    asExpression: '(qualityScore + deliveryScore + serviceScore) / 3',
    generatedType: 'VIRTUAL',
  })
  overallScore: number;

  @Column({ comment: '评价内容', type: 'text', nullable: true })
  content: string;

  @Column({ comment: '评价时间', type: 'date' })
  evaluationDate: Date;
}
